package com.saernuosi;

import cn.bmob.v3.Bmob;
import cn.bmob.v3.BmobUser;
import cn.bmob.v3.datatype.BmobFile;
import cn.bmob.v3.listener.SaveListener;

import com.saernuosi.R;
import com.saernuosi.bean.Video;
import com.saernuosi.content.Values;

import android.os.Bundle;
import android.util.Log;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Toast;

public class SplashActivity extends Activity {

    private BmobUser user;

	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bmob.initialize(SplashActivity.this, Values.BMOB_KEY);
        user = BmobUser.getCurrentUser(SplashActivity.this);
        BmobFile file = new BmobFile();
        setContentView(R.layout.activity_splash);
        View splash = findViewById(R.id.splash);
        AlphaAnimation ani = new AlphaAnimation(1, 1);
        ani.setDuration(1500);
        splash.startAnimation(ani);
        ani.setAnimationListener(new AnimationListener() {
			
			@Override
			public void onAnimationStart(Animation animation) {
				
			}
			
			@Override
			public void onAnimationRepeat(Animation animation) {
				
			}
			
			@Override
			public void onAnimationEnd(Animation animation) {
				if(user!=null){
					Intent intent1 = new Intent(SplashActivity.this,HomeActivity.class);
					startActivity(intent1);
					overridePendingTransition(R.anim.splash_login_ani_in, R.anim.splash_login_ani_out);
					finish();
				}else{
					Intent intent = new Intent(SplashActivity.this,LoginActivity.class);
					startActivity(intent);
					overridePendingTransition(R.anim.splash_login_ani_in, R.anim.splash_login_ani_out);
					finish();
				}
				
			}
		});
    }


}
